using System;
#if SILVERLIGHT
using jSLCore.Client.Presentation.AuthorizeService;
#endif
using jSLCore.Utility.Extensions;

namespace jSLCore.Client.Presentation.jBinding.BaseConverters
{
    public class jImageSourceConverter : jChainConverter
    {

        public override object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            if(value is byte[])return ((byte[])value).ConvertToImageSource();
#if SILVERLIGHT
            if (value is Binary) return ((Binary) value).Bytes.ConvertToImageSource();
#endif
            return null;
        }

        public override object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    } 

}